package com.atguigu.factorymethod;

import java.util.Scanner;

/**
 * @ClassName OrderPizza
 * @Description TODO
 * @Author HongJian-Yang
 * @Date 2020/6/17 0:25
 * @Version 1.0
 */
public abstract class OrderPizza {
    public OrderPizza() {
        Pizza pizza = null;
        String orderType;
        do {
            orderType = getType();
            pizza = createPizza(orderType);
            if (pizza != null) {
                pizza.prepare();
                pizza.bake();
                pizza.cut();
                pizza.box();
            } else {
                System.out.println("下单失败,请重试l");
            }
        } while (true);
    }

    abstract Pizza createPizza(String orderType); //留给子类实现

    public String getType() {
        Scanner scanner = new Scanner(System.in);
        return scanner.next();
    }
}
